package com.info.zhiduoduo.common.excelconverter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.info.zhiduoduo.common.utils.StringUtil;

/**
 * 招标类型 1：邀约 2：公开
 */
public class BidTypeConverter implements Converter<Integer> {

	@Override
	public Class supportJavaTypeKey() {
		return null;
	}

	@Override
	public CellDataTypeEnum supportExcelTypeKey() {
		return null;
	}

	@Override
	public Integer convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration)
			throws Exception {
		String val = cellData.getStringValue();
		if (StringUtil.isEmpty(val)) {
			return null;
		} else if (val.equals("邀约")) {
			return 1;
		} else if (val.equals("公开")) {
			return 2;
		} else {
			return null;
		}
	}

	@Override
	public CellData convertToExcelData(Integer integer, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration)
			throws Exception {
		if (integer == null) {
			return new CellData("");
		} else if (integer == 1) {
			return new CellData("邀约");
		} else if (integer == 2) {
			return new CellData("公开");
		} else {
			return new CellData("");
		}
	}
}
